<?php
use common\components\helpers\Fun;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\components\extenders\MenuManage;
use doumiaoduo\layer\LayerIframeWidget;
use doumiaoduo\layer\LayerAsset;
LayerAsset::register($this);

LayerIframeWidget::widget(['button'=>"['添加','取消']"]);
?>
    <div class="yx-cnt-box yx-radius2">
        <div class="yx-praise-box">
            <div class="yx-search-class">
                <a href="<?=Fun::url(['customer/details','id'=>\Yii::$app->request->get('id')])?>">
                    <button type="button" class="btn yx-back-list yx-radius5 yx-width110">返回上级</button>
                </a>
                <div class="yx-bgf7 yx-height108">
                    <h4 class="yx-teacher-praise yx-floatl ">会员姓名：<?= $customer->name ?></h4>
                    <h4 class="yx-teacher-praise yx-pl20 yx-floatl">当前可用余额：<span class="yx-color2cb4f3 yx-font16"><?= $account ?></span>元</h4>
                    <div class="yx-clear"></div>
                </div>
                <div class="yx-class-box yx-pt18 yx-pb0">
                    <div class="docs-main">
                        <table class="tablesaw table yx-table1 yx-table3 yx-table5 table-striped with-check"  >
                            <thead>
                            <tr class="yx-bgd2f6ec">
                                <th>课程</th>
                                <th>老师</th>
                                <th>教室</th>
                                <th>上课时间</th>
                                <th>课次价格</th>
                                <th>模式</th>
                            </tr>
                            </thead>
                            <tr>
                                <td><?=$goods->name?></td>
                                <td><?=isset($goodsAttr['teacher'])?$goodsAttr['teacher']:''?></td>
                                <td><?=isset($goodsAttr['classroom_name'])?$goodsAttr['classroom_name']:''?></td>
                                <td><?=$classTime?></td>
                                <td><?=$lesson_price?></td>
                                <td>技教学</td>
                            </tr>
                        </table>
                       <?php if($artModel != null) { ?>
                        <table class="tablesaw table yx-table1 yx-table3 yx-table5 table-striped with-check"  >
                            <thead>
                            <tr class="yx-bgd2f6ec">
                                <th>课程</th>
                                <th>类型</th>
                                <th>上课时间</th>
                                <th>课次价格</th>
                                <th>模式</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tr>
                                <td><?=$artModel->title?></td>
                                <td><?php
                                       switch ($artModel->type){
                                           case 1:
                                               echo '益智';
                                               break;
                                           case 2:
                                               echo '音乐';
                                               break;
                                           case 3:
                                               echo '形体';
                                               break;
                                       }
                                    ?></td>
                                <td><?=\common\components\helpers\Util::getWeek($artModel->class_day).$artModel->star_time.'-'.$artModel->end_time?></td>
                                <td><?=round($artModel->price/$artModel->class_count)?></td>
                                <td>技教学</td>
                                <td><a class="btn yx-radius2 yx-d-card yx-bg94d5a2" data-url="<?=Fun::url(['goodsskill/viewgroup','id'=>$artModel->id])?>" data-size="1000*600" data-name="查看" rel="dialog-show-iframe" >查看</a></td>
                            </tr>
                        </table>
                       <?php } ?>
                    </div>
                </div>
            </div>

            <div class="yx-class-box yx-bt" style="padding-top: 10px">
                <?php $form = ActiveForm::begin(['enableAjaxValidation' => true, 'enableClientValidation' => false,'options'=>['class'=>'form-validate form-horizontal']]); ?>
                <div class="control-group" style="display: none">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['total_amount']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'total_amount', ['template' => '{input}{error}'])->hiddenInput(); ?>
                    </div>
                </div>
                <div class="control-group" style="display: none">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['goods_id']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'goods_id', ['template' => '{input}{error}'])->hiddenInput(['value'=>$goods->id]); ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['final_amount']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'final_amount', ['template' => '{input}{error}{hint}'])->textInput(['style' => 'width:180px', 'readonly' => 'true', 'value' => 0, 'class' => 'input-text yx-width168']) ?>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['skill_class_num']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'skill_class_num', ['template' => '{input}{error}{hint}'])->dropDownList(['12'=>12,'24'=>24],['prompt'=>'请选择','style' => 'width:180px', 'class' => 'input-text yx-width168'])->hint('转化的课次数') ?>
                    </div>
                </div>
                <div class="control-group" style="display: none">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['skill_class_price']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'skill_class_price', ['template' => '{input}{error}{hint}'])->hiddenInput(['value'=>$lesson_price])?>
                    </div>
                </div>
                <?php if($artModel != null) { ?>
                <div class="control-group">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['art_class_num']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'art_class_num', ['template' => '{input}{error}{hint}'])->dropDownList($artModelLesson,['prompt'=>'请选择','style' => 'width:180px', 'class' => 'input-text yx-width168'])->hint('转化的课次数') ?>
                    </div>
                </div>
                    <div class="control-group" style="display: none">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['art_class_price']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'art_class_price', ['template' => '{input}{error}{hint}'])->hiddenInput(['value'=>round($artModel->price/$artModel->class_count)])?>
                    </div>
                </div>
               <?php } ?>
                <div class="control-group">
                    <label class="control-label control-label1 yx-mr25" for="inputTime"><?= $model->attributeLabels()['remarks']; ?></label>
                    <div class="controls">
                        <?= $form->field($model, 'remarks', ['template' => '{input}{error}{hint}'])->textarea(['rows' => 2, 'style' => 'width:180px', 'class' => 'textarea_editor yx-width510 yx-height56']) ?>
                    </div>
                </div>
                <div class="yx-button-group">
                    <button type="submit" id="dosubmit" class="btn yx-save yx-radius50">提交</button>
                    <button type="button" data-toggle="button" class="btn yx-close1 yx-radius50 yx-ml4" onclick="history.go(-1)">返回</button>
                </div>
                <?php ActiveForm::end(); ?>
            </div>

        </div>
    </div>
<?php
$js=<<<JS
   $('#orders-skill_class_num').on('change',function() {
       var skill_class_num = parseInt($(this).val());
       var skill_class_price = parseInt($('#orders-skill_class_price').val());
       var art_class_num = $('#orders-art_class_num')?$('#orders-art_class_num').val() != ''?parseInt($('#orders-art_class_num').val()):0:0;
       var art_class_price = $('#orders-art_class_price')?parseInt($('#orders-art_class_price').val()):0;
       var total = (skill_class_num*skill_class_price) + (art_class_num*art_class_price);
       $('#orders-final_amount').val(total);
       $('#orders-total_amount').val(total);
   });
    
    $('#orders-art_class_num').on('change',function() {
       var art_class_num = parseInt($(this).val());
       var art_class_price = parseInt($('#orders-art_class_price').val());
       var skill_class_num = $('#orders-skill_class_num').val() != ''?parseInt($('#orders-skill_class_num').val()):0;
       var skill_class_price = $('#orders-skill_class_price')?parseInt($('#orders-skill_class_price').val()):0;
       var total = (skill_class_num*skill_class_price) + (art_class_num*art_class_price);
       $('#orders-final_amount').val(total);
       $('#orders-total_amount').val(total);
   });
JS;
\Yii::$app->view->registerJs($js);
?>